<HTML><HEAD>
<!--
    -----------------
    StatusBar Time #2
    -----------------
-->

<SCRIPT LANGUAGE="JavaScript"><!-- hide from old browsers

/*
    THE JAVASCRIPT COOKBOOK by Erica Sadun, webrx@mindspring.com
    Copyright (C)1998 by Charles River Media.  All Rights Reserved.
    
    This applet can only be re-used or modifed by license holders of the
    JavaScript Cookbook CD-ROM.  Credit must be given in the source
    code and this copyright notice must be maintained. If you do
    not hold a license to the JavaScript Cookbook, you may NOT
    duplicate or modify this code for your own use.

    Use at your own risk. No warranty is given or implied of the suitability 
    of this applet for any specific application. Neither Erica Sadun nor 
    Charles River Media will be held responsible for any unwanted effects 
    due to the use of this applet or any derivative. 
*/

var JSCActive = 0

function setMessage()
{
    now = new Date()
    window.status = now.toLocaleString()
    JSCTimeOutID = window.setTimeout('setMessage()',1000)
    JSCActive = 1
}

function toggle()
{
    if (JSCActive == 0)
    {
        JSCTimeOutID = window.setTimeout('setMessage()',1000);
        JSCActive = 1
    }
    else
    {
        clearTimeout(JSCTimeOutID)
        JSCActive = 0
        window.status = "Press Again to Restart Clock"
    }
}


<!-- done hiding --></SCRIPT></HEAD>

<BODY bgcolor="ffffff" link="0000ff" vlink="770077"
onload="JSCTimeOutID = window.setTimeout('setMessage()',500);">
    
    <FONT COLOR="007777"><H1>Status Bar Clock #2</H1></FONT>
    <BLOCKQUOTE><FONT COLOR="770000">
        This script automatically sets the status bar text to the current
        time. It refreshes the time every half-second. (Press the 
        button below to toggle the clock.  The clock is "on" by default).
    </FONT></BLOCKQUOTE>
    
    <CENTER><FORM>
        <INPUT TYPE="button" VALUE="TOGGLE THE CLOCK" NAME="stopgo"
            onClick="toggle()">
    </FORM></CENTER>

    <BR><BR>
    
    <FONT COLOR="007777"><H2><IMG SRC="../GRAFX/UTENS.JPG" WIDTH=80 HEIGHT=50
    ALIGN = LEFT>Discussion</H2></FONT>
    <FONT SIZE=4>
        This script sets a time-out in the BODY tag to automatically
        load the <FONT color="770000">setMessage()</FONT> function.
        In this function, the time-out is reloaded. Time-out evaluates
        expressions after a set number of milliseconds ellapse. The
        variable <FONT color="770000">JSCActive</FONT> keeps track of
        whether or not the real-time clock is active.  Please note
        that some early versions of Netscape Navigator 2.0 do not
        produce the correct time.
        
        
        <h3>The BODY tag</h3>
        <font color="770000"><pre><null
        >&lt;BODY bgcolor="ffffff" link="0000ff" vlink="770077"<br><null
        >    onload="JSCTimeOutID = window.setTimeout('setMessage()',500);"&gt;<br><null
        ></pre></font>

        <h3>Renewing the TimeOut in setMessage()</h3>
        <font color="770000"><pre><null
        >JSCTimeOutID = window.setTimeout('setMessage()',1000);<br><null
        ></pre></font>
        
        <h3>Stopping & Restarting the Clock with the Button</h3>
        <font color="770000"><pre><null
        >&lt;INPUT TYPE="button" VALUE="TOGGLE THE CLOCK"<br><null
        >onClick="toggle()"&gt;<br><null
        ></pre></font>

        <h3>Stopping the Clock in setMessage()</h3>
        <font color="770000"><pre><null
        >clearTimeout(JSCTimeOutID)<br><null
        ></pre></font>
    </FONT>        


<h5>Copyright &copy;1998 by Charles River Media, All Rights Reserved</h5>
</BODY>
</HTML>